package com.example.whac_a_mole;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Activity_top extends AppCompatActivity {
private ListView listView;
private SharedPreferences preferences;
private Set<String> top;
    private static final String TAG = "LSK";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_top);
        setTitle("打地鼠-高分榜");
        listView=findViewById(R.id.list);
        List<Map<String,String>> list=new DataBase(Activity_top.this).selectall();
        String[] arr1=new String[]{"num","mode","user","time1","mark","time2"};
        int[] arr2=new int[]{R.id.num,R.id.mode,R.id.user,R.id.time1,R.id.mark,R.id.time2};
       /* Iterator<String> it = top.iterator();
        while(it.hasNext())
        {
            String str = it.next();
            String[] split = str.split("@");
            Log.i(TAG, Arrays.toString(split));
            HashMap<String,String> map=new HashMap<>();
            for (int i = 0; i < split.length; i++) {
                map.put(arr1[i],split[i]);
            }
            list.add(map);

        }*/

        SimpleAdapter adapter=new SimpleAdapter(Activity_top.this,list,R.layout.adapter_top,arr1,arr2);
        listView.setAdapter(adapter);


    }
}
